# 指定基础镜像
FROM  caddy:2.10

# 标签
LABEL authors="hrc"

# 声明构建参数
ARG BUILD_DATE
ARG GIT_COMMIT

# 设置代码存储目录--容器中的位置
WORKDIR /app

# 将本机文件复制到容器工作目录中
COPY ./web/dist /app/dist
COPY ./api/release/  /app/release

COPY cmd.sh /app/cmd.sh

# 安装 openssh-client
RUN sed -i 's|https://dl-cdn.alpinelinux.org/alpine|https://mirrors.aliyun.com/alpine|g' /etc/apk/repositories
RUN apk add --no-cache openssh-client 



# 写入构建时间戳 与Git 提交 ID 到 version
RUN echo "build.date=${BUILD_DATE}" > /app/version && \
    echo "git.commit=${GIT_COMMIT}" >> /app/version


# 声明容器运行时监听的端口
EXPOSE 8080

VOLUME /app/Caddyfile
# 缓存证书
VOLUME /data

# CMD 会被覆盖
CMD ["sh", "-c", "caddy start & sleep 1 && sh /app/cmd.sh"]